package com.liuwei.msmall.product.controller.web;

import com.liuwei.msmall.product.service.SkuInfoService;
import com.liuwei.msmall.product.vo.SkuItemVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.util.concurrent.ExecutionException;

/**
 * @Classname ItemController
 * @Description TODO
 * @Date 2020/6/22 18:49
 * @Created by 刘
 */
@Controller
public class ItemController {

    @Autowired
    private SkuInfoService skuInfoService;


    @GetMapping("/{skuId}.html")
    public String item(@PathVariable("skuId") Long skuId, Model model) throws ExecutionException, InterruptedException {

        //准备商品信息
        System.out.println("拿到的skuId:"+skuId);

        SkuItemVo itemVo= skuInfoService.item(skuId);
        model.addAttribute("item",itemVo);
        return "item";
    }

}
